import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
// 路由组件
import Home from '@/pages/Home'
import Search from '@/pages/Search'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Account from '@/pages/Account'
import Qcode from '@/pages/Qcode'
export default new VueRouter({
	routes:[
		{
			path:'/home',
			component: Home,
			meta:{
				isShow: true
			}
		},
		{
			path:'/search/:keyword?',
			component: Search,
			name: 'search',
			meta:{
				isShow: true
			},
			// 路由组件能不能传递参数
			// 布尔值写法 会把parmas参数全部给路由组件
			props: true,
			// 对象写法: 额外给路由组件传递一些props
			props:{a:1,b:2},
			// 函数写法: 可以把pramas参数和query参数传给路由组件
			props: ($route)=>{
				return {keyword:$route.params.keyword,k:$route.query.k}
			}
			
		},
		{
			path:'/Login',
			component: Login,
			meta:{
				isShow: false
			},
			children : [
				{
							path : 'account',
							name : Account,
							component : Account
				},
				{
							path : 'qcode',
							name : Qcode,
							component : Qcode
				}
			]
		},
		{
			path:'/Register',
			component: Register,
			meta:{
				isShow: false
			}
		}
	]
});